package com.lagou.service.impl;

import com.lagou.common.ResponseCode;
import com.lagou.mapper.AccountMapper;
import com.lagou.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AccountServiceImpl implements IAccountService {
    @Autowired
    AccountMapper mapper;

    @Override
    public int transfer(String inName, String outName, Double money) {
        try {
            mapper.transferIn(inName,money);
            mapper.transferOut(outName,money);
            return ResponseCode.SUCCESS.getCode();
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseCode.ERROR.getCode();
        }
    }
}
